/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package mywebapp.impl;

import mywebapp.MywebappFactory;
import mywebapp.MywebappPackage;
import mywebapp.WebApp;

import mywebapp.dao.DaoPackage;

import mywebapp.dao.impl.DaoPackageImpl;

import mywebapp.util.MywebappValidator;
import mywebapp.webpage.WebpagePackage;

import mywebapp.webpage.impl.WebpagePackageImpl;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;

import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.impl.EPackageImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Package</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class MywebappPackageImpl extends EPackageImpl implements MywebappPackage {
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private EClass webAppEClass = null;

	/**
	 * Creates an instance of the model <b>Package</b>, registered with
	 * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
	 * package URI value.
	 * <p>Note: the correct way to create the package is via the static
	 * factory method {@link #init init()}, which also performs
	 * initialization of the package, or returns the registered package,
	 * if one already exists.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see org.eclipse.emf.ecore.EPackage.Registry
	 * @see mywebapp.MywebappPackage#eNS_URI
	 * @see #init()
	 * @generated
	 */
	private MywebappPackageImpl() {
		super(eNS_URI, MywebappFactory.eINSTANCE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private static boolean isInited = false;

	/**
	 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
	 * 
	 * <p>This method is used to initialize {@link MywebappPackage#eINSTANCE} when that field is accessed.
	 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #eNS_URI
	 * @see #createPackageContents()
	 * @see #initializePackageContents()
	 * @generated
	 */
	public static MywebappPackage init() {
		if (isInited) return (MywebappPackage)EPackage.Registry.INSTANCE.getEPackage(MywebappPackage.eNS_URI);

		// Obtain or create and register package
		MywebappPackageImpl theMywebappPackage = (MywebappPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof MywebappPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new MywebappPackageImpl());

		isInited = true;

		// Obtain or create and register interdependencies
		DaoPackageImpl theDaoPackage = (DaoPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(DaoPackage.eNS_URI) instanceof DaoPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(DaoPackage.eNS_URI) : DaoPackage.eINSTANCE);
		WebpagePackageImpl theWebpagePackage = (WebpagePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(WebpagePackage.eNS_URI) instanceof WebpagePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(WebpagePackage.eNS_URI) : WebpagePackage.eINSTANCE);

		// Create package meta-data objects
		theMywebappPackage.createPackageContents();
		theDaoPackage.createPackageContents();
		theWebpagePackage.createPackageContents();

		// Initialize created meta-data
		theMywebappPackage.initializePackageContents();
		theDaoPackage.initializePackageContents();
		theWebpagePackage.initializePackageContents();

		// Register package validator
		EValidator.Registry.INSTANCE.put
			(theMywebappPackage, 
			 new EValidator.Descriptor() {
				 public EValidator getEValidator() {
					 return MywebappValidator.INSTANCE;
				 }
			 });

		// Mark meta-data to indicate it can't be changed
		theMywebappPackage.freeze();

  
		// Update the registry and return the package
		EPackage.Registry.INSTANCE.put(MywebappPackage.eNS_URI, theMywebappPackage);
		return theMywebappPackage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EClass getWebApp() {
		return webAppEClass;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EReference getWebApp_Entities() {
		return (EReference)webAppEClass.getEStructuralFeatures().get(0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EReference getWebApp_Pages() {
		return (EReference)webAppEClass.getEStructuralFeatures().get(1);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EAttribute getWebApp_Name() {
		return (EAttribute)webAppEClass.getEStructuralFeatures().get(2);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EReference getWebApp_Main() {
		return (EReference)webAppEClass.getEStructuralFeatures().get(3);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MywebappFactory getMywebappFactory() {
		return (MywebappFactory)getEFactoryInstance();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private boolean isCreated = false;

	/**
	 * Creates the meta-model objects for the package.  This method is
	 * guarded to have no affect on any invocation but its first.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void createPackageContents() {
		if (isCreated) return;
		isCreated = true;

		// Create classes and their features
		webAppEClass = createEClass(WEB_APP);
		createEReference(webAppEClass, WEB_APP__ENTITIES);
		createEReference(webAppEClass, WEB_APP__PAGES);
		createEAttribute(webAppEClass, WEB_APP__NAME);
		createEReference(webAppEClass, WEB_APP__MAIN);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private boolean isInitialized = false;

	/**
	 * Complete the initialization of the package and its meta-model.  This
	 * method is guarded to have no affect on any invocation but its first.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void initializePackageContents() {
		if (isInitialized) return;
		isInitialized = true;

		// Initialize package
		setName(eNAME);
		setNsPrefix(eNS_PREFIX);
		setNsURI(eNS_URI);

		// Obtain other dependent packages
		DaoPackage theDaoPackage = (DaoPackage)EPackage.Registry.INSTANCE.getEPackage(DaoPackage.eNS_URI);
		WebpagePackage theWebpagePackage = (WebpagePackage)EPackage.Registry.INSTANCE.getEPackage(WebpagePackage.eNS_URI);

		// Add subpackages
		getESubpackages().add(theDaoPackage);
		getESubpackages().add(theWebpagePackage);

		// Add supertypes to classes

		// Initialize classes and features; add operations and parameters
		initEClass(webAppEClass, WebApp.class, "WebApp", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEReference(getWebApp_Entities(), theDaoPackage.getEntity(), null, "entities", null, 0, -1, WebApp.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getWebApp_Pages(), theWebpagePackage.getPage(), null, "pages", null, 0, -1, WebApp.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getWebApp_Name(), ecorePackage.getEString(), "name", null, 1, 1, WebApp.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getWebApp_Main(), theWebpagePackage.getPage(), null, "main", null, 1, 1, WebApp.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		// Create resource
		createResource(eNS_URI);

		// Create annotations
		// http://www.eclipse.org/emf/2002/Ecore
		createEcoreAnnotations();
		// http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot
		createPivotAnnotations();
	}

	/**
	 * Initializes the annotations for <b>http://www.eclipse.org/emf/2002/Ecore</b>.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected void createEcoreAnnotations() {
		String source = "http://www.eclipse.org/emf/2002/Ecore";		
		addAnnotation
		  (this, 
		   source, 
		   new String[] {
			 "invocationDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
			 "settingDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
			 "validationDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot"
		   });		
		addAnnotation
		  (webAppEClass, 
		   source, 
		   new String[] {
			 "constraints", "not_same_page_name not_same_entity_name"
		   });	
	}

	/**
	 * Initializes the annotations for <b>http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot</b>.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected void createPivotAnnotations() {
		String source = "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot";				
		addAnnotation
		  (webAppEClass, 
		   source, 
		   new String[] {
			 "not_same_page_name", "pages->forAll(a : Page, b : Page | a <> b implies a.name <> b.name)",
			 "not_same_entity_name", "entities->forAll(a : Entity, b : Entity | a <> b implies a.name <> b.name)"
		   });
	}

} //MywebappPackageImpl
